package utils.map;

import java.util.Date;
import java.util.Map;

import utils.parallelrun.ParallelRunImitation;

public class Test {
    public static void main(String[] args) {
        final Map<String, String> map = new TimeLimitMap<>(10);
        map.put("zb", "左边");
        map.put("yw", "业务");
        // System.out.println(map.get("zb"));
        // System.out.println(map.get("zb"));
        // System.out.println(map.get("zb"));
        // System.out.println(map.get("zb"));
        // System.out.println(map.get("zb"));
        ParallelRunImitation test = new ParallelRunImitation(100, new Runnable() {

            @Override
            public void run() {
                System.out.println(map.get("zb"));
            }
        });
        test.run();

        Map<String, String> dateMap = new DateLimitMap<>(10L);
        dateMap.put("zb", "左边");
        dateMap.put("yw", "业务");
        System.out.println(dateMap.get("zb"));
        try {
            Thread.sleep(5);
            System.out.println("sleep success");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(dateMap.get("yw"));
        System.out.println(dateMap.get("zb"));
        try {
            Thread.sleep(6);
            System.out.println("sleep success");
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println(dateMap.get("yw"));
        System.out.println(dateMap.get("zb"));

        Map<String, String> tempMap = new DateLimitMap<>(60 * 60 * 1000L);
        tempMap.put("zb", "左边");
        tempMap.put("yw", "业务");
        System.out.println("start date " + new Date());
        while (true) {
            try {
                Thread.sleep(1000);
                System.out.println("sleep success");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(tempMap.get("zb"));
            System.out.println("\nthis date is " + new Date());
        }
    }
}
